﻿using AutoMapper;

namespace Journeo_backend.Configuration
{
    public class AutoMapperProfile : Profile
    {
        public AutoMapperProfile()
        {
            // CreateMap<Source, Destination>();

            // User
            CreateMap<User, UserInfoVO>();
            CreateMap<UserInfoVO, User>();
            CreateMap<User, UserRegisterDTO>();
            CreateMap<UserRegisterDTO, User>();
            CreateMap<User, UserLoginVO>();
            CreateMap<UserLoginVO, User>();
            CreateMap<User, UserUpdateDTO>();
            CreateMap<UserUpdateDTO, User>();

            // PlanAttraction
            CreateMap<PlanAttractionDTO, PlanAttraction>();
            CreateMap<PlanAttraction, PlanAttractionDTO>();


            // TransportationPlan
            CreateMap<TransportationPlan, TransportationPlanDTO>();
            CreateMap<TransportationPlanDTO, TransportationPlan>();


            // Attraction
            CreateMap<AttractionCommentDTO, AttractionComment>();
            CreateMap<AttractionComment, AttractionCommentDTO>();
            CreateMap<AttractionComment, AttractionCommentVO>();
            CreateMap<AttractionCommentVO, AttractionComment>();

            // 替换longtitude，latitude为amapLongtitude，amapLatitude
            CreateMap<Attraction, AttractionVO>()
                .ForMember(dest => dest.Latitude, opt => opt.MapFrom(src => src.AmapLatitude))
                .ForMember(dest => dest.Longitude, opt => opt.MapFrom(src => src.AmapLongitude));



            // TravelPlan
            CreateMap<TravelPlan, TravelPlanDTO>();
            CreateMap<TravelPlanDTO, TravelPlan>();
        }
    }
}
